package com.jic.member.impl.power;

import java.lang.Long;
import java.util.List;


import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.power.MememberUserLedger;
import com.jic.member.mapper.power.MememberUserLedgerMapper;
import com.jic.member.service.power.MememberUserLedgerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 会员积分台账表
 * @author : 
 * @email : 
 * @since : 2020-06-16 11:40:47
 * @version : v1.0.0
 */
@Service
public class MememberUserLedgerServiceImpl implements MememberUserLedgerService {

    @Autowired
    private MememberUserLedgerMapper mememberUserLedgerMapper;

    @Override
    public long insert(MememberUserLedger mememberUserLedger) {
        long flag = mememberUserLedgerMapper.insert(mememberUserLedger);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return mememberUserLedgerMapper.delete(id);
    }

    @Override
    public long update(MememberUserLedger mememberUserLedger) {
        return mememberUserLedgerMapper.update(mememberUserLedger);
    }

    @Override
    public MememberUserLedger queryByPrimaryKey(Long id){
        return mememberUserLedgerMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<MememberUserLedger> query(MememberUserLedger mememberUserLedger){
        return mememberUserLedgerMapper.query(mememberUserLedger);
    }

    @Override
    public PageResult<MememberUserLedger> queryPage(MememberUserLedger mememberUserLedger, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MememberUserLedger> list = mememberUserLedgerMapper.queryPage(startIndex, pageQuery.getLimit(), mememberUserLedger);
        long count = mememberUserLedgerMapper.queryPageCount(mememberUserLedger);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}